<?php
class m_ekstrakulikuler extends Model{
    var $table = "ekstrakulikuler";
    
    function getListEkstrakulikuler(){
        $query = $this->db->query("select * from ekstrakulikuler");
        if($query->num_rows() > 0){
            return $query->result_array();
        }else return array();
    }
    function getEkstrakulikulerById($id){
        $query = $this->db->query("select * from ekstrakulikuler where id = '$id'");
        if($query->num_rows() > 0){
            return $query->result_array();
        }else return array();
    }
    function searchEkstrakulikuler($nama){
        $query = $this->db->query("select * from ekstrakulikuler where locate('$nama',nama) > 0 order by locate('$nama',nama)");
        if($query->num_rows() > 0){
            return $query->result_array();
        }else return array();
    }
    function addEkstrakulikuler($data){
        $insert = $this->db->insert($this->table,$data);
        if($insert){
            return TRUE;
        }else return FALSE;
    }
    function editEkstrakulikuler($data){
        $this->db->where('id',$data['id']);
        $update = $this->db->update($this->table,$data);
        if(!$update){
            return FALSE;
        }else return TRUE;
    }
    function deleteEkstrakulikuler($id){
        $delete = $this->db->delete($this->table,array('id'=>$id));
        if(!$delete){
            return FALSE;
        }else return TRUE;
    }
}
?>
